{
 "metadata": {
  "language": "Julia",
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Prerequisites\n",
      "=============\n",
      "\n",
      "As referred to below, `Index.h` is the libclang API header, available within the Clang source tree at `include/clang-c/Index.h` ([suggested download location](https://raw.github.com/llvm-mirror/clang/master/include/clang-c/Index.h)).\n",
      "\n",
      "The following definitions should be adjusted to match the appropriate paths on your system, if libclang is installed separately from Julia."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "indexh         = joinpath(JULIA_HOME, \"../include/clang-c/Index.h\")\n",
      "clang_includes = [joinpath(JULIA_HOME, \"../lib/clang/3.3/include\"), joinpath(dirname(indexh), \"..\")]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 1,
       "text": [
        "2-element Array{ASCIIString,1}:\n",
        " \"/cmn/julia/usr/bin/../lib/clang/3.3/include\"                          \n",
        " \"/cmn/julia/usr/bin/../../deps/llvm-3.3/tools/clang/include/clang-c/..\""
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Printing Enums\n",
      "=============="
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "using Clang.cindex\n",
      "\n",
      "top = parse_header(indexh; includes=clang_includes, diagnostics=true)\n",
      "\n",
      "function print_enums(enumdef::EnumDecl)\n",
      "    for enum in children(enumdef)\n",
      "        println(\"  const \", name(enum), \" = \", value(enum))\n",
      "    end\n",
      "end\n",
      "\n",
      "for cursor in children(top)\n",
      "    # Skip cursors not in target file\n",
      "    if (basename(cu_file(cursor)) != basename(indexh)) continue end\n",
      "    \n",
      "    got_enum = false\n",
      "    if isa(cursor, EnumDecl)\n",
      "        #if (name(cursor) == \"\") continue end\n",
      "        println(\"# Enum: \", name(cursor))\n",
      "        print_enums(cursor)\n",
      "        got_enum = true\n",
      "    elseif isa(cursor, TypedefDecl)\n",
      "        td_children = children(cursor)\n",
      "        td_children.size == 0 && continue\n",
      "        \n",
      "        td_cursor = td_children[1]\n",
      "        if isa(td_cursor, EnumDecl)\n",
      "            println(\"# Typedef Enum: \", name(td_cursor))\n",
      "            print_enums(td_cursor)\n",
      "            got_enum = true\n",
      "        end\n",
      "    end\n",
      "end"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "# Enum: CXAvailabilityKind"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  const CXAvailability_Available = 0\n",
        "  const CXAvailability_Deprecated = 1\n",
        "  const CXAvailability_NotAvailable = 2\n",
        "  const CXAvailability_NotAccessible = 3\n",
        "# Enum: \n",
        "  const CXGlobalOpt_None = 0\n",
        "  const CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 1\n",
        "  const CXGlobalOpt_ThreadBackgroundPriorityForEditing = 2\n",
        "  const CXGlobalOpt_ThreadBackgroundPriorityForAll = 3\n",
        "# Typedef Enum: \n",
        "  const CXGlobalOpt_None = 0\n",
        "  const CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 1\n",
        "  const CXGlobalOpt_ThreadBackgroundPriorityForEditing = 2\n",
        "  const CXGlobalOpt_ThreadBackgroundPriorityForAll = 3\n",
        "# Enum: CXDiagnosticSeverity\n",
        "  const CXDiagnostic_Ignored = 0\n",
        "  const CXDiagnostic_Note = 1\n",
        "  const CXDiagnostic_Warning = 2\n",
        "  const CXDiagnostic_Error = 3\n",
        "  const CXDiagnostic_Fatal = 4\n",
        "# Enum: CXLoadDiag_Error\n",
        "  const CXLoadDiag_None = 0\n",
        "  const CXLoadDiag_Unknown = 1\n",
        "  const CXLoadDiag_CannotLoad = 2\n",
        "  const CXLoadDiag_InvalidFile = 3\n",
        "# Enum: CXDiagnosticDisplayOptions\n",
        "  const CXDiagnostic_DisplaySourceLocation = 1\n",
        "  const CXDiagnostic_DisplayColumn = 2\n",
        "  const CXDiagnostic_DisplaySourceRanges = 4\n",
        "  const CXDiagnostic_DisplayOption = 8\n",
        "  const CXDiagnostic_DisplayCategoryId = 16\n",
        "  const CXDiagnostic_DisplayCategoryName = 32\n",
        "# Enum: CXTranslationUnit_Flags\n",
        "  const CXTranslationUnit_None = 0\n",
        "  const CXTranslationUnit_DetailedPreprocessingRecord = 1\n",
        "  const CXTranslationUnit_Incomplete = 2\n",
        "  const CXTranslationUnit_PrecompiledPreamble = 4\n",
        "  const CXTranslationUnit_CacheCompletionResults = 8\n",
        "  const CXTranslationUnit_ForSerialization = 16\n",
        "  const CXTranslationUnit_CXXChainedPCH = 32\n",
        "  const CXTranslationUnit_SkipFunctionBodies = 64\n",
        "  const CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 128\n",
        "# Enum: CXSaveTranslationUnit_Flags\n",
        "  const CXSaveTranslationUnit_None = 0\n",
        "# Enum: CXSaveError\n",
        "  const CXSaveError_None = 0\n",
        "  const CXSaveError_Unknown = 1\n",
        "  const CXSaveError_TranslationErrors = 2\n",
        "  const CXSaveError_InvalidTU = 3\n",
        "# Enum: CXReparse_Flags\n",
        "  const CXReparse_None = 0\n",
        "# Enum: CXTUResourceUsageKind\n",
        "  const CXTUResourceUsage_AST = 1\n",
        "  const CXTUResourceUsage_Identifiers = 2\n",
        "  const CXTUResourceUsage_Selectors = 3\n",
        "  const CXTUResourceUsage_GlobalCompletionResults = 4\n",
        "  const CXTUResourceUsage_SourceManagerContentCache = 5\n",
        "  const CXTUResourceUsage_AST_SideTables = 6\n",
        "  const CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7\n",
        "  const CXTUResourceUsage_SourceManager_Membuffer_MMap = 8\n",
        "  const CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9\n",
        "  const CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10\n",
        "  const CXTUResourceUsage_Preprocessor = 11\n",
        "  const CXTUResourceUsage_PreprocessingRecord = 12\n",
        "  const CXTUResourceUsage_SourceManager_DataStructures = 13\n",
        "  const CXTUResourceUsage_Preprocessor_HeaderSearch = 14\n",
        "  const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = 1\n",
        "  const CXTUResourceUsage_MEMORY_IN_BYTES_END = 14\n",
        "  const CXTUResourceUsage_First = 1\n",
        "  const CXTUResourceUsage_Last = 14\n",
        "# Enum: CXCursorKind\n",
        "  const CXCursor_UnexposedDecl = 1\n",
        "  const CXCursor_StructDecl = 2\n",
        "  const CXCursor_UnionDecl = 3\n",
        "  const CXCursor_ClassDecl = 4\n",
        "  const CXCursor_EnumDecl = 5\n",
        "  const CXCursor_FieldDecl = 6\n",
        "  const CXCursor_EnumConstantDecl = 7\n",
        "  const CXCursor_FunctionDecl = 8\n",
        "  const CXCursor_VarDecl = 9\n",
        "  const CXCursor_ParmDecl = 10\n",
        "  const CXCursor_ObjCInterfaceDecl = 11\n",
        "  const CXCursor_ObjCCategoryDecl = 12\n",
        "  const CXCursor_ObjCProtocolDecl = 13\n",
        "  const CXCursor_ObjCPropertyDecl = 14\n",
        "  const CXCursor_ObjCIvarDecl = 15\n",
        "  const CXCursor_ObjCInstanceMethodDecl = 16\n",
        "  const CXCursor_ObjCClassMethodDecl = 17\n",
        "  const CXCursor_ObjCImplementationDecl = 18\n",
        "  const CXCursor_ObjCCategoryImplDecl = 19\n",
        "  const CXCursor_TypedefDecl = 20\n",
        "  const CXCursor_CXXMethod = 21\n",
        "  const CXCursor_Namespace = 22\n",
        "  const CXCursor_LinkageSpec = 23\n",
        "  const CXCursor_Constructor = 24\n",
        "  const CXCursor_Destructor = 25\n",
        "  const CXCursor_ConversionFunction = 26\n",
        "  const CXCursor_TemplateTypeParameter = 27\n",
        "  const CXCursor_NonTypeTemplateParameter = 28\n",
        "  const CXCursor_TemplateTemplateParameter = 29\n",
        "  const CXCursor_FunctionTemplate = 30\n",
        "  const CXCursor_ClassTemplate = 31\n",
        "  const CXCursor_ClassTemplatePartialSpecialization = 32\n",
        "  const CXCursor_NamespaceAlias = 33\n",
        "  const CXCursor_UsingDirective = 34\n",
        "  const CXCursor_UsingDeclaration = 35\n",
        "  const CXCursor_TypeAliasDecl = 36\n",
        "  const CXCursor_ObjCSynthesizeDecl = 37\n",
        "  const CXCursor_ObjCDynamicDecl = 38\n",
        "  const CXCursor_CXXAccessSpecifier = 39\n",
        "  const CXCursor_FirstDecl = 1\n",
        "  const CXCursor_LastDecl = 39\n",
        "  const CXCursor_FirstRef = 40\n",
        "  const CXCursor_ObjCSuperClassRef = 40\n",
        "  const CXCursor_ObjCProtocolRef = 41\n",
        "  const CXCursor_ObjCClassRef = 42\n",
        "  const CXCursor_TypeRef = 43\n",
        "  const CXCursor_CXXBaseSpecifier = 44\n",
        "  const CXCursor_TemplateRef = 45\n",
        "  const CXCursor_NamespaceRef = 46\n",
        "  const CXCursor_MemberRef = 47\n",
        "  const CXCursor_LabelRef = 48\n",
        "  const CXCursor_OverloadedDeclRef = 49\n",
        "  const CXCursor_VariableRef = 50\n",
        "  const CXCursor_LastRef = 50\n",
        "  const CXCursor_FirstInvalid = 70\n",
        "  const CXCursor_InvalidFile = 70\n",
        "  const CXCursor_NoDeclFound = 71\n",
        "  const CXCursor_NotImplemented = 72\n",
        "  const CXCursor_InvalidCode = 73\n",
        "  const CXCursor_LastInvalid = 73\n",
        "  const CXCursor_FirstExpr = 100\n",
        "  const CXCursor_UnexposedExpr = 100\n",
        "  const CXCursor_DeclRefExpr = 101\n",
        "  const CXCursor_MemberRefExpr = 102\n",
        "  const CXCursor_CallExpr = 103\n",
        "  const CXCursor_ObjCMessageExpr = 104\n",
        "  const CXCursor_BlockExpr = 105\n",
        "  const CXCursor_IntegerLiteral = 106\n",
        "  const CXCursor_FloatingLiteral = 107\n",
        "  const CXCursor_ImaginaryLiteral = 108\n",
        "  const CXCursor_StringLiteral = 109\n",
        "  const CXCursor_CharacterLiteral = 110\n",
        "  const CXCursor_ParenExpr = 111\n",
        "  const CXCursor_UnaryOperator = 112\n",
        "  const CXCursor_ArraySubscriptExpr = 113\n",
        "  const CXCursor_BinaryOperator = 114\n",
        "  const CXCursor_CompoundAssignOperator = 115\n",
        "  const CXCursor_ConditionalOperator = 116\n",
        "  const CXCursor_CStyleCastExpr = 117\n",
        "  const CXCursor_CompoundLiteralExpr = 118\n",
        "  const CXCursor_InitListExpr = 119\n",
        "  const CXCursor_AddrLabelExpr = 120\n",
        "  const CXCursor_StmtExpr = 121\n",
        "  const CXCursor_GenericSelectionExpr = 122\n",
        "  const CXCursor_GNUNullExpr = 123\n",
        "  const CXCursor_CXXStaticCastExpr = 124\n",
        "  const CXCursor_CXXDynamicCastExpr = 125\n",
        "  const CXCursor_CXXReinterpretCastExpr = 126\n",
        "  const CXCursor_CXXConstCastExpr = 127\n",
        "  const CXCursor_CXXFunctionalCastExpr = 128\n",
        "  const CXCursor_CXXTypeidExpr = 129\n",
        "  const CXCursor_CXXBoolLiteralExpr = 130\n",
        "  const CXCursor_CXXNullPtrLiteralExpr = 131\n",
        "  const CXCursor_CXXThisExpr = 132\n",
        "  const CXCursor_CXXThrowExpr = 133\n",
        "  const CXCursor_CXXNewExpr = 134\n",
        "  const CXCursor_CXXDeleteExpr = 135\n",
        "  const CXCursor_UnaryExpr = 136\n",
        "  const CXCursor_ObjCStringLiteral = 137\n",
        "  const CXCursor_ObjCEncodeExpr = 138\n",
        "  const CXCursor_ObjCSelectorExpr = 139\n",
        "  const CXCursor_ObjCProtocolExpr = 140\n",
        "  const CXCursor_ObjCBridgedCastExpr = 141\n",
        "  const CXCursor_PackExpansionExpr = 142\n",
        "  const CXCursor_SizeOfPackExpr = 143\n",
        "  const CXCursor_LambdaExpr = 144\n",
        "  const CXCursor_ObjCBoolLiteralExpr = 145\n",
        "  const CXCursor_ObjCSelfExpr = 146\n",
        "  const CXCursor_LastExpr = 146\n",
        "  const CXCursor_FirstStmt = 200\n",
        "  const CXCursor_UnexposedStmt = 200\n",
        "  const CXCursor_LabelStmt = 201\n",
        "  const CXCursor_CompoundStmt = 202\n",
        "  const CXCursor_CaseStmt = 203\n",
        "  const CXCursor_DefaultStmt = 204\n",
        "  const CXCursor_IfStmt = 205\n",
        "  const CXCursor_SwitchStmt = 206\n",
        "  const CXCursor_WhileStmt = 207\n",
        "  const CXCursor_DoStmt = 208\n",
        "  const CXCursor_ForStmt = 209\n",
        "  const CXCursor_GotoStmt = 210\n",
        "  const CXCursor_IndirectGotoStmt = 211\n",
        "  const CXCursor_ContinueStmt = 212\n",
        "  const CXCursor_BreakStmt = 213\n",
        "  const CXCursor_ReturnStmt = 214\n",
        "  const CXCursor_GCCAsmStmt = 215\n",
        "  const CXCursor_AsmStmt = 215\n",
        "  const CXCursor_ObjCAtTryStmt = 216\n",
        "  const CXCursor_ObjCAtCatchStmt = 217\n",
        "  const CXCursor_ObjCAtFinallyStmt = 218\n",
        "  const CXCursor_ObjCAtThrowStmt = 219\n",
        "  const CXCursor_ObjCAtSynchronizedStmt = 220\n",
        "  const CXCursor_ObjCAutoreleasePoolStmt = 221\n",
        "  const CXCursor_ObjCForCollectionStmt = 222\n",
        "  const CXCursor_CXXCatchStmt = 223\n",
        "  const CXCursor_CXXTryStmt = 224\n",
        "  const CXCursor_CXXForRangeStmt = 225\n",
        "  const CXCursor_SEHTryStmt = 226\n",
        "  const CXCursor_SEHExceptStmt = 227\n",
        "  const CXCursor_SEHFinallyStmt = 228\n",
        "  const CXCursor_MSAsmStmt = 229\n",
        "  const CXCursor_NullStmt = 230\n",
        "  const CXCursor_DeclStmt = 231\n",
        "  const CXCursor_LastStmt = 231\n",
        "  const CXCursor_TranslationUnit = 300\n",
        "  const CXCursor_FirstAttr = 400\n",
        "  const CXCursor_UnexposedAttr = 400\n",
        "  const CXCursor_IBActionAttr = 401\n",
        "  const CXCursor_IBOutletAttr = 402\n",
        "  const CXCursor_IBOutletCollectionAttr = 403\n",
        "  const CXCursor_CXXFinalAttr = 404\n",
        "  const CXCursor_CXXOverrideAttr = 405\n",
        "  const CXCursor_AnnotateAttr = 406\n",
        "  const CXCursor_AsmLabelAttr = 407\n",
        "  const CXCursor_LastAttr = 407\n",
        "  const CXCursor_PreprocessingDirective = 500\n",
        "  const CXCursor_MacroDefinition = 501\n",
        "  const CXCursor_MacroExpansion = 502\n",
        "  const CXCursor_MacroInstantiation = 502\n",
        "  const CXCursor_InclusionDirective = 503\n",
        "  const CXCursor_FirstPreprocessing = 500\n",
        "  const CXCursor_LastPreprocessing = 503\n",
        "  const CXCursor_ModuleImportDecl = 600\n",
        "  const CXCursor_FirstExtraDecl = 600\n",
        "  const CXCursor_LastExtraDecl = 600\n",
        "# Enum: CXLinkageKind\n",
        "  const CXLinkage_Invalid = 0\n",
        "  const CXLinkage_NoLinkage = 1\n",
        "  const CXLinkage_Internal = 2\n",
        "  const CXLinkage_UniqueExternal = 3\n",
        "  const CXLinkage_External = 4\n",
        "# Enum: CXLanguageKind\n",
        "  const CXLanguage_Invalid = 0\n",
        "  const CXLanguage_C = 1\n",
        "  const CXLanguage_ObjC = 2\n",
        "  const CXLanguage_CPlusPlus = 3\n",
        "# Enum: CXTypeKind\n",
        "  const CXType_Invalid = 0\n",
        "  const CXType_Unexposed = 1\n",
        "  const CXType_Void = 2\n",
        "  const CXType_Bool = 3\n",
        "  const CXType_Char_U = 4\n",
        "  const CXType_UChar = 5\n",
        "  const CXType_Char16 = 6\n",
        "  const CXType_Char32 = 7\n",
        "  const CXType_UShort = 8\n",
        "  const CXType_UInt = 9\n",
        "  const CXType_ULong = 10\n",
        "  const CXType_ULongLong = 11\n",
        "  const CXType_UInt128 = 12\n",
        "  const CXType_Char_S = 13\n",
        "  const CXType_SChar = 14\n",
        "  const CXType_WChar = 15\n",
        "  const CXType_Short = 16\n",
        "  const CXType_Int = 17\n",
        "  const CXType_Long = 18\n",
        "  const CXType_LongLong = 19\n",
        "  const CXType_Int128 = 20\n",
        "  const CXType_Float = 21\n",
        "  const CXType_Double = 22\n",
        "  const CXType_LongDouble = 23\n",
        "  const CXType_NullPtr = 24\n",
        "  const CXType_Overload = 25\n",
        "  const CXType_Dependent = 26\n",
        "  const CXType_ObjCId = 27\n",
        "  const CXType_ObjCClass = 28\n",
        "  const CXType_ObjCSel = 29\n",
        "  const CXType_FirstBuiltin = 2\n",
        "  const CXType_LastBuiltin = 29\n",
        "  const CXType_Complex = 100\n",
        "  const CXType_Pointer = 101\n",
        "  const CXType_BlockPointer = 102\n",
        "  const CXType_LValueReference = 103\n",
        "  const CXType_RValueReference = 104\n",
        "  const CXType_Record = 105\n",
        "  const CXType_Enum = 106\n",
        "  const CXType_Typedef = 107\n",
        "  const CXType_ObjCInterface = 108\n",
        "  const CXType_ObjCObjectPointer = 109\n",
        "  const CXType_FunctionNoProto = 110\n",
        "  const CXType_FunctionProto = 111\n",
        "  const CXType_ConstantArray = 112\n",
        "  const CXType_Vector = 113\n",
        "# Enum: CXCallingConv\n",
        "  const CXCallingConv_Default = 0\n",
        "  const CXCallingConv_C = 1\n",
        "  const CXCallingConv_X86StdCall = 2\n",
        "  const CXCallingConv_X86FastCall = 3\n",
        "  const CXCallingConv_X86ThisCall = 4\n",
        "  const CXCallingConv_X86Pascal = 5\n",
        "  const CXCallingConv_AAPCS = 6\n",
        "  const CXCallingConv_AAPCS_VFP = 7\n",
        "  const CXCallingConv_PnaclCall = 8\n",
        "  const CXCallingConv_IntelOclBicc = 9\n",
        "  const CXCallingConv_Invalid = 100\n",
        "  const CXCallingConv_Unexposed = 200\n",
        "# Enum: CXTypeLayoutError\n",
        "  const CXTypeLayoutError_Invalid = -1\n",
        "  const CXTypeLayoutError_Incomplete = -2\n",
        "  const CXTypeLayoutError_Dependent = -3\n",
        "  const CXTypeLayoutError_NotConstantSize = -4\n",
        "  const CXTypeLayoutError_InvalidFieldName = -5\n",
        "# Enum: CX_CXXAccessSpecifier\n",
        "  const CX_CXXInvalidAccessSpecifier = 0\n",
        "  const CX_CXXPublic = 1\n",
        "  const CX_CXXProtected = 2\n",
        "  const CX_CXXPrivate = 3\n",
        "# Enum: CXChildVisitResult\n",
        "  const CXChildVisit_Break = 0\n",
        "  const CXChildVisit_Continue = 1\n",
        "  const CXChildVisit_Recurse = 2\n",
        "# Enum: \n",
        "  const CXObjCPropertyAttr_noattr = 0\n",
        "  const CXObjCPropertyAttr_readonly = 1\n",
        "  const CXObjCPropertyAttr_getter = 2\n",
        "  const CXObjCPropertyAttr_assign = 4\n",
        "  const CXObjCPropertyAttr_readwrite = 8\n",
        "  const CXObjCPropertyAttr_retain = 16\n",
        "  const CXObjCPropertyAttr_copy = 32\n",
        "  const CXObjCPropertyAttr_nonatomic = 64\n",
        "  const CXObjCPropertyAttr_setter = 128\n",
        "  const CXObjCPropertyAttr_atomic = 256\n",
        "  const CXObjCPropertyAttr_weak = 512\n",
        "  const CXObjCPropertyAttr_strong = 1024\n",
        "  const CXObjCPropertyAttr_unsafe_unretained = 2048\n",
        "# Typedef Enum: \n",
        "  const CXObjCPropertyAttr_noattr = 0\n",
        "  const CXObjCPropertyAttr_readonly = 1\n",
        "  const CXObjCPropertyAttr_getter = 2\n",
        "  const CXObjCPropertyAttr_assign = 4\n",
        "  const CXObjCPropertyAttr_readwrite = 8\n",
        "  const CXObjCPropertyAttr_retain = 16\n",
        "  const CXObjCPropertyAttr_copy = 32\n",
        "  const CXObjCPropertyAttr_nonatomic = 64\n",
        "  const CXObjCPropertyAttr_setter = 128\n",
        "  const CXObjCPropertyAttr_atomic = 256\n",
        "  const CXObjCPropertyAttr_weak = 512\n",
        "  const CXObjCPropertyAttr_strong = 1024\n",
        "  const CXObjCPropertyAttr_unsafe_unretained = 2048\n",
        "# Enum: \n",
        "  const CXObjCDeclQualifier_None = 0\n",
        "  const CXObjCDeclQualifier_In = 1\n",
        "  const CXObjCDeclQualifier_Inout = 2\n",
        "  const CXObjCDeclQualifier_Out = 4\n",
        "  const CXObjCDeclQualifier_Bycopy = 8\n",
        "  const CXObjCDeclQualifier_Byref = 16\n",
        "  const CXObjCDeclQualifier_Oneway = 32\n",
        "# Typedef Enum: \n",
        "  const CXObjCDeclQualifier_None = 0\n",
        "  const CXObjCDeclQualifier_In = 1\n",
        "  const CXObjCDeclQualifier_Inout = 2\n",
        "  const CXObjCDeclQualifier_Out = 4\n",
        "  const CXObjCDeclQualifier_Bycopy = 8\n",
        "  const CXObjCDeclQualifier_Byref = 16\n",
        "  const CXObjCDeclQualifier_Oneway = 32\n",
        "# Enum: CXCommentKind\n",
        "  const CXComment_Null = 0\n",
        "  const CXComment_Text = 1\n",
        "  const CXComment_InlineCommand = 2\n",
        "  const CXComment_HTMLStartTag = 3\n",
        "  const CXComment_HTMLEndTag = 4\n",
        "  const CXComment_Paragraph = 5\n",
        "  const CXComment_BlockCommand = 6\n",
        "  const CXComment_ParamCommand = 7\n",
        "  const CXComment_TParamCommand = 8\n",
        "  const CXComment_VerbatimBlockCommand = 9\n",
        "  const CXComment_VerbatimBlockLine = 10\n",
        "  const CXComment_VerbatimLine = 11\n",
        "  const CXComment_FullComment = 12\n",
        "# Enum: CXCommentInlineCommandRenderKind\n",
        "  const CXCommentInlineCommandRenderKind_Normal = 0\n",
        "  const CXCommentInlineCommandRenderKind_Bold = 1\n",
        "  const CXCommentInlineCommandRenderKind_Monospaced = 2\n",
        "  const CXCommentInlineCommandRenderKind_Emphasized = 3\n",
        "# Enum: CXCommentParamPassDirection\n",
        "  const CXCommentParamPassDirection_In = 0\n",
        "  const CXCommentParamPassDirection_Out = 1\n",
        "  const CXCommentParamPassDirection_InOut = 2\n",
        "# Enum: CXNameRefFlags\n",
        "  const CXNameRange_WantQualifier = 1\n",
        "  const CXNameRange_WantTemplateArgs = 2\n",
        "  const CXNameRange_WantSinglePiece = 4\n",
        "# Enum: CXTokenKind\n",
        "  const CXToken_Punctuation = 0\n",
        "  const CXToken_Keyword = 1\n",
        "  const CXToken_Identifier = 2\n",
        "  const CXToken_Literal = 3\n",
        "  const CXToken_Comment = 4\n",
        "# Typedef Enum: CXTokenKind\n",
        "  const CXToken_Punctuation = 0\n",
        "  const CXToken_Keyword = 1\n",
        "  const CXToken_Identifier = 2\n",
        "  const CXToken_Literal = 3\n",
        "  const CXToken_Comment = 4\n",
        "# Enum: CXCompletionChunkKind\n",
        "  const CXCompletionChunk_Optional = 0\n",
        "  const CXCompletionChunk_TypedText = 1\n",
        "  const CXCompletionChunk_Text = 2\n",
        "  const CXCompletionChunk_Placeholder = 3\n",
        "  const CXCompletionChunk_Informative = 4\n",
        "  const CXCompletionChunk_CurrentParameter = 5\n",
        "  const CXCompletionChunk_LeftParen = 6\n",
        "  const CXCompletionChunk_RightParen = 7\n",
        "  const CXCompletionChunk_LeftBracket = 8\n",
        "  const CXCompletionChunk_RightBracket = 9\n",
        "  const CXCompletionChunk_LeftBrace = 10\n",
        "  const CXCompletionChunk_RightBrace = 11\n",
        "  const CXCompletionChunk_LeftAngle = 12\n",
        "  const CXCompletionChunk_RightAngle = 13\n",
        "  const CXCompletionChunk_Comma = 14\n",
        "  const CXCompletionChunk_ResultType = 15\n",
        "  const CXCompletionChunk_Colon = 16\n",
        "  const CXCompletionChunk_SemiColon = 17\n",
        "  const CXCompletionChunk_Equal = 18\n",
        "  const CXCompletionChunk_HorizontalSpace = 19\n",
        "  const CXCompletionChunk_VerticalSpace = 20\n",
        "# Enum: CXCodeComplete_Flags\n",
        "  const CXCodeComplete_IncludeMacros = 1\n",
        "  const CXCodeComplete_IncludeCodePatterns = 2\n",
        "  const CXCodeComplete_IncludeBriefComments = 4\n",
        "# Enum: CXCompletionContext\n",
        "  const CXCompletionContext_Unexposed = 0\n",
        "  const CXCompletionContext_AnyType = 1\n",
        "  const CXCompletionContext_AnyValue = 2\n",
        "  const CXCompletionContext_ObjCObjectValue = 4\n",
        "  const CXCompletionContext_ObjCSelectorValue = 8\n",
        "  const CXCompletionContext_CXXClassTypeValue = 16\n",
        "  const CXCompletionContext_DotMemberAccess = 32\n",
        "  const CXCompletionContext_ArrowMemberAccess = 64\n",
        "  const CXCompletionContext_ObjCPropertyAccess = 128\n",
        "  const CXCompletionContext_EnumTag = 256\n",
        "  const CXCompletionContext_UnionTag = 512\n",
        "  const CXCompletionContext_StructTag = 1024\n",
        "  const CXCompletionContext_ClassTag = 2048\n",
        "  const CXCompletionContext_Namespace = 4096\n",
        "  const CXCompletionContext_NestedNameSpecifier = 8192\n",
        "  const CXCompletionContext_ObjCInterface = 16384\n",
        "  const CXCompletionContext_ObjCProtocol = 32768\n",
        "  const CXCompletionContext_ObjCCategory = 65536\n",
        "  const CXCompletionContext_ObjCInstanceMessage = 131072\n",
        "  const CXCompletionContext_ObjCClassMessage = 262144\n",
        "  const CXCompletionContext_ObjCSelectorName = 524288\n",
        "  const CXCompletionContext_MacroName = 1048576\n",
        "  const CXCompletionContext_NaturalLanguage = 2097152\n",
        "  const CXCompletionContext_Unknown = 4194303\n",
        "# Enum: CXVisitorResult\n",
        "  const CXVisit_Break = 0\n",
        "  const CXVisit_Continue = 1\n",
        "# Enum: \n",
        "  const CXResult_Success = 0\n",
        "  const CXResult_Invalid = 1\n",
        "  const CXResult_VisitBreak = 2\n",
        "# Typedef Enum: \n",
        "  const CXResult_Success = 0\n",
        "  const CXResult_Invalid = 1\n",
        "  const CXResult_VisitBreak = 2\n",
        "# Enum: \n",
        "  const CXIdxEntity_Unexposed = 0\n",
        "  const CXIdxEntity_Typedef = 1\n",
        "  const CXIdxEntity_Function = 2\n",
        "  const CXIdxEntity_Variable = 3\n",
        "  const CXIdxEntity_Field = 4\n",
        "  const CXIdxEntity_EnumConstant = 5\n",
        "  const CXIdxEntity_ObjCClass = 6\n",
        "  const CXIdxEntity_ObjCProtocol = 7\n",
        "  const CXIdxEntity_ObjCCategory = 8\n",
        "  const CXIdxEntity_ObjCInstanceMethod = 9\n",
        "  const CXIdxEntity_ObjCClassMethod = 10\n",
        "  const CXIdxEntity_ObjCProperty = 11\n",
        "  const CXIdxEntity_ObjCIvar = 12\n",
        "  const CXIdxEntity_Enum = 13\n",
        "  const CXIdxEntity_Struct = 14\n",
        "  const CXIdxEntity_Union = 15\n",
        "  const CXIdxEntity_CXXClass = 16\n",
        "  const CXIdxEntity_CXXNamespace = 17\n",
        "  const CXIdxEntity_CXXNamespaceAlias = 18\n",
        "  const CXIdxEntity_CXXStaticVariable = 19\n",
        "  const CXIdxEntity_CXXStaticMethod = 20\n",
        "  const CXIdxEntity_CXXInstanceMethod = 21\n",
        "  const CXIdxEntity_CXXConstructor = 22\n",
        "  const CXIdxEntity_CXXDestructor = 23\n",
        "  const CXIdxEntity_CXXConversionFunction = 24\n",
        "  const CXIdxEntity_CXXTypeAlias = 25\n",
        "  const CXIdxEntity_CXXInterface = 26\n",
        "# Typedef Enum: \n",
        "  const CXIdxEntity_Unexposed = 0\n",
        "  const CXIdxEntity_Typedef = 1\n",
        "  const CXIdxEntity_Function = 2\n",
        "  const CXIdxEntity_Variable = 3\n",
        "  const CXIdxEntity_Field = 4\n",
        "  const CXIdxEntity_EnumConstant = 5\n",
        "  const CXIdxEntity_ObjCClass = 6\n",
        "  const CXIdxEntity_ObjCProtocol = 7\n",
        "  const CXIdxEntity_ObjCCategory = 8\n",
        "  const CXIdxEntity_ObjCInstanceMethod = 9\n",
        "  const CXIdxEntity_ObjCClassMethod = 10\n",
        "  const CXIdxEntity_ObjCProperty = 11\n",
        "  const CXIdxEntity_ObjCIvar = 12\n",
        "  const CXIdxEntity_Enum = 13\n",
        "  const CXIdxEntity_Struct = 14\n",
        "  const CXIdxEntity_Union = 15\n",
        "  const CXIdxEntity_CXXClass = 16\n",
        "  const CXIdxEntity_CXXNamespace = 17\n",
        "  const CXIdxEntity_CXXNamespaceAlias = 18\n",
        "  const CXIdxEntity_CXXStaticVariable = 19\n",
        "  const CXIdxEntity_CXXStaticMethod = 20\n",
        "  const CXIdxEntity_CXXInstanceMethod = 21\n",
        "  const CXIdxEntity_CXXConstructor = 22\n",
        "  const CXIdxEntity_CXXDestructor = 23\n",
        "  const CXIdxEntity_CXXConversionFunction = 24\n",
        "  const CXIdxEntity_CXXTypeAlias = 25\n",
        "  const CXIdxEntity_CXXInterface = 26\n",
        "# Enum: \n",
        "  const CXIdxEntityLang_None = 0\n",
        "  const CXIdxEntityLang_C = 1\n",
        "  const CXIdxEntityLang_ObjC = 2\n",
        "  const CXIdxEntityLang_CXX = 3\n",
        "# Typedef Enum: \n",
        "  const CXIdxEntityLang_None = 0\n",
        "  const CXIdxEntityLang_C = 1\n",
        "  const CXIdxEntityLang_ObjC = 2\n",
        "  const CXIdxEntityLang_CXX = 3\n",
        "# Enum: \n",
        "  const CXIdxEntity_NonTemplate = 0\n",
        "  const CXIdxEntity_Template = 1\n",
        "  const CXIdxEntity_TemplatePartialSpecialization = 2\n",
        "  const CXIdxEntity_TemplateSpecialization = 3\n",
        "# Typedef Enum: \n",
        "  const CXIdxEntity_NonTemplate = 0\n",
        "  const CXIdxEntity_Template = 1\n",
        "  const CXIdxEntity_TemplatePartialSpecialization = 2\n",
        "  const CXIdxEntity_TemplateSpecialization = 3\n",
        "# Enum: \n",
        "  const CXIdxAttr_Unexposed = 0\n",
        "  const CXIdxAttr_IBAction = 1\n",
        "  const CXIdxAttr_IBOutlet = 2\n",
        "  const CXIdxAttr_IBOutletCollection = 3\n",
        "# Typedef Enum: \n",
        "  const CXIdxAttr_Unexposed = 0\n",
        "  const CXIdxAttr_IBAction = 1\n",
        "  const CXIdxAttr_IBOutlet = 2\n",
        "  const CXIdxAttr_IBOutletCollection = 3\n",
        "# Enum: \n",
        "  const CXIdxDeclFlag_Skipped = 1\n",
        "# Typedef Enum: \n",
        "  const CXIdxDeclFlag_Skipped = 1\n",
        "# Enum: \n",
        "  const CXIdxObjCContainer_ForwardRef = 0\n",
        "  const CXIdxObjCContainer_Interface = 1\n",
        "  const CXIdxObjCContainer_Implementation = 2\n",
        "# Typedef Enum: \n",
        "  const CXIdxObjCContainer_ForwardRef = 0\n",
        "  const CXIdxObjCContainer_Interface = 1\n",
        "  const CXIdxObjCContainer_Implementation = 2\n",
        "# Enum: \n",
        "  const CXIdxEntityRef_Direct = 1\n",
        "  const CXIdxEntityRef_Implicit = 2\n",
        "# Typedef Enum: \n",
        "  const CXIdxEntityRef_Direct = 1\n",
        "  const CXIdxEntityRef_Implicit = 2\n",
        "# Enum: \n",
        "  const CXIndexOpt_None = 0\n",
        "  const CXIndexOpt_SuppressRedundantRefs = 1\n",
        "  const CXIndexOpt_IndexFunctionLocalSymbols = 2\n",
        "  const CXIndexOpt_IndexImplicitTemplateInstantiations = 4\n",
        "  const CXIndexOpt_SuppressWarnings = 8\n",
        "  const CXIndexOpt_SkipParsedBodiesInSession = 16\n",
        "# Typedef Enum: \n",
        "  const CXIndexOpt_None = 0\n",
        "  const CXIndexOpt_SuppressRedundantRefs = 1\n",
        "  const CXIndexOpt_IndexFunctionLocalSymbols = 2\n",
        "  const CXIndexOpt_IndexImplicitTemplateInstantiations = 4\n",
        "  const CXIndexOpt_SuppressWarnings = 8\n",
        "  const CXIndexOpt_SkipParsedBodiesInSession = 16\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Print Functions\n",
      "===============\n",
      "\n",
      "Expected output:\n",
      "\n",
      "```\n",
      "Number of cursors in TranslationUnit: 679\n",
      "Functions:\n",
      "  clang_createIndex(CXIndex,Int,Int,)\n",
      "  clang_disposeIndex(Typedef,)\n",
      "  clang_CXIndex_setGlobalOptions(Typedef,UInt,)\n",
      "  clang_CXIndex_getGlobalOptions(Typedef,)\n",
      "  clang_getFileName(CXString,Typedef,)\n",
      "  clang_getFileTime(time_t,Typedef,)\n",
      "  ...\n",
      "```\n",
      "\n",
      "Note: number of cursors may vary depending on the definitions activated in previous includes based on system type and configuration."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "using Clang.cindex\n",
      "\n",
      "get_it(t::TypedefDecl) = get_it(cindex.getTypedefDeclUnderlyingType(t))\n",
      "get_it(d::ParmDecl)    = get_it(cu_type(d))\n",
      "get_it(t::TypeRef)     = spelling(t)\n",
      "get_it(t::Pointer) = string(\"Ptr{\", get_it(cindex.getPointeeType(t)), \"}\")\n",
      "get_it(t::CLType)  = spelling(t)\n",
      "\n",
      "get_it(c::CLCursor) = get_it(cindex.getCursorType(c))\n",
      "get_it(f::FunctionDecl) = spelling(f)\n",
      "\n",
      "function print_function(f::FunctionDecl)\n",
      "    rt = return_type(f)\n",
      "    print(\"  \", get_it(f))\n",
      "    print(\"(\")\n",
      "    for a in children(f)\n",
      "        if !(isa(a, TypeRef) || isa(a, ParmDecl)) break end\n",
      "        print(get_it(a))\n",
      "        print(\",\")\n",
      "    end\n",
      "    print(\")\\n\")\n",
      "end\n",
      "\n",
      "function dump_functions(header::String)\n",
      "    tu = parse_header(header; includes=clang_includes)\n",
      "    tu_children = children(tu)\n",
      "    \n",
      "    println(\"Number of cursors in TranslationUnit: \", length(tu_children))\n",
      "    println(\"Functions:\")\n",
      "    for node in children(tu)\n",
      "        # Skip anything outside of the TU\n",
      "        if (basename(cu_file(node)) != basename(header))\n",
      "            continue\n",
      "        end\n",
      "        if isa(node, FunctionDecl)\n",
      "            print_function(node)\n",
      "        end\n",
      "    end\n",
      "end\n",
      "\n",
      "dump_functions(indexh)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of cursors in TranslationUnit: 679"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Functions:\n",
        "  clang_createIndex(CXIndex,Int,Int,)\n",
        "  clang_disposeIndex(Typedef,)\n",
        "  clang_CXIndex_setGlobalOptions(Typedef,UInt,)\n",
        "  clang_CXIndex_getGlobalOptions(Typedef,)\n",
        "  clang_getFileName(CXString,Typedef,)\n",
        "  clang_getFileTime(time_t,Typedef,)\n",
        "  clang_getFileUniqueID(Typedef,Ptr{Typedef}"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        ",)\n",
        "  clang_isFileMultipleIncludeGuarded(Typedef,Typedef,)\n",
        "  clang_getFile(CXFile,Typedef,Ptr{Char_S},)\n",
        "  clang_getNullLocation(CXSourceLocation,)\n",
        "  clang_equalLocations(Typedef,Typedef,)\n",
        "  clang_getLocation(CXSourceLocation,Typedef,Typedef,UInt,UInt,)\n",
        "  clang_getLocationForOffset(CXSourceLocation,Typedef,Typedef,UInt,)\n",
        "  clang_Location_isInSystemHeader(Typedef,)\n",
        "  clang_getNullRange(CXSourceRange,)\n",
        "  clang_getRange(CXSourceRange,Typedef,Typedef,)\n",
        "  clang_equalRanges(Typedef,Typedef,)\n",
        "  clang_Range_isNull(Typedef,)\n",
        "  clang_getExpansionLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_getPresumedLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_getInstantiationLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_getSpellingLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_getFileLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_getRangeStart(CXSourceLocation,Typedef,)\n",
        "  clang_getRangeEnd(CXSourceLocation,Typedef,)\n",
        "  clang_getNumDiagnosticsInSet(Typedef,)\n",
        "  clang_getDiagnosticInSet(CXDiagnostic,Typedef,UInt,)\n",
        "  clang_loadDiagnostics(CXDiagnosticSet,Ptr{Char_S},Ptr{Unexposed},Ptr{Typedef},)\n",
        "  clang_disposeDiagnosticSet(Typedef,)\n",
        "  clang_getChildDiagnostics(CXDiagnosticSet,Typedef,)\n",
        "  clang_getNumDiagnostics(Typedef,)\n",
        "  clang_getDiagnostic(CXDiagnostic,Typedef,UInt,)\n",
        "  clang_getDiagnosticSetFromTU(CXDiagnosticSet,Typedef,)\n",
        "  clang_disposeDiagnostic(Typedef,)\n",
        "  clang_formatDiagnostic(CXString,Typedef,UInt,)\n",
        "  clang_defaultDiagnosticDisplayOptions()\n",
        "  clang_getDiagnosticSeverity(enum CXDiagnosticSeverity,Typedef,)\n",
        "  clang_getDiagnosticLocation(CXSourceLocation,Typedef,)\n",
        "  clang_getDiagnosticSpelling(CXString,Typedef,)\n",
        "  clang_getDiagnosticOption(CXString,Typedef,Ptr{Typedef},)\n",
        "  clang_getDiagnosticCategory(Typedef,)\n",
        "  clang_getDiagnosticCategoryName()\n",
        "  clang_getDiagnosticCategoryText(CXString,Typedef,)\n",
        "  clang_getDiagnosticNumRanges(Typedef,)\n",
        "  clang_getDiagnosticRange(CXSourceRange,Typedef,UInt,)\n",
        "  clang_getDiagnosticNumFixIts(Typedef,)\n",
        "  clang_getDiagnosticFixIt(CXString,Typedef,UInt,Ptr{Typedef},)\n",
        "  clang_getTranslationUnitSpelling(CXString,Typedef,)\n",
        "  clang_createTranslationUnitFromSourceFile(CXTranslationUnit,Typedef,Ptr{Char_S},Int,Ptr{Ptr{Char_S}},UInt,Ptr{Unexposed},)\n",
        "  clang_createTranslationUnit(CXTranslationUnit,Typedef,Ptr{Char_S},)\n",
        "  clang_defaultEditingTranslationUnitOptions()\n",
        "  clang_parseTranslationUnit(CXTranslationUnit,Typedef,Ptr{Char_S},Ptr{Ptr{Char_S}},Int,Ptr{Unexposed},UInt,UInt,)\n",
        "  clang_defaultSaveOptions(Typedef,)\n",
        "  clang_saveTranslationUnit(Typedef,Ptr{Char_S},UInt,)\n",
        "  clang_disposeTranslationUnit(Typedef,)\n",
        "  clang_defaultReparseOptions(Typedef,)\n",
        "  clang_reparseTranslationUnit(Typedef,UInt,Ptr{Unexposed},UInt,)\n",
        "  clang_getTUResourceUsageName(Unexposed,)\n",
        "  clang_getCXTUResourceUsage(CXTUResourceUsage,Typedef,)\n",
        "  clang_disposeCXTUResourceUsage(Typedef,)\n",
        "  clang_getNullCursor(CXCursor,)\n",
        "  clang_getTranslationUnitCursor(CXCursor,Typedef,)\n",
        "  clang_equalCursors(Typedef,Typedef,)\n",
        "  clang_Cursor_isNull(Typedef,)\n",
        "  clang_hashCursor(Typedef,)\n",
        "  clang_getCursorKind(enum CXCursorKind,Typedef,)\n",
        "  clang_isDeclaration(Unexposed,)\n",
        "  clang_isReference(Unexposed,)\n",
        "  clang_isExpression(Unexposed,)\n",
        "  clang_isStatement(Unexposed,)\n",
        "  clang_isAttribute(Unexposed,)\n",
        "  clang_isInvalid(Unexposed,)\n",
        "  clang_isTranslationUnit(Unexposed,)\n",
        "  clang_isPreprocessing(Unexposed,)\n",
        "  clang_isUnexposed(Unexposed,)\n",
        "  clang_getCursorLinkage(enum CXLinkageKind,Typedef,)\n",
        "  clang_getCursorAvailability(enum CXAvailabilityKind,Typedef,)\n",
        "  clang_getCursorPlatformAvailability(Typedef,Ptr{Int},Ptr{Typedef},Ptr{Int},Ptr{Typedef},Ptr{Typedef},Int,)\n",
        "  clang_disposeCXPlatformAvailability(Ptr{Typedef},)\n",
        "  clang_getCursorLanguage(enum CXLanguageKind,Typedef,)\n",
        "  clang_Cursor_getTranslationUnit(CXTranslationUnit,Typedef,)\n",
        "  clang_createCXCursorSet(CXCursorSet,)\n",
        "  clang_disposeCXCursorSet(Typedef,)\n",
        "  clang_CXCursorSet_contains(Typedef,Typedef,)\n",
        "  clang_CXCursorSet_insert(Typedef,Typedef,)\n",
        "  clang_getCursorSemanticParent(CXCursor,Typedef,)\n",
        "  clang_getCursorLexicalParent(CXCursor,Typedef,)\n",
        "  clang_getOverriddenCursors(Typedef,Ptr{Ptr{Typedef}},Ptr{UInt},)\n",
        "  clang_disposeOverriddenCursors(Ptr{Typedef},)\n",
        "  clang_getIncludedFile(CXFile,Typedef,)\n",
        "  clang_getCursor(CXCursor,Typedef,Typedef,)\n",
        "  clang_getCursorLocation(CXSourceLocation,Typedef,)\n",
        "  clang_getCursorExtent(CXSourceRange,Typedef,)\n",
        "  clang_getCursorType(CXType,Typedef,)\n",
        "  clang_getTypeSpelling(CXString,Typedef,)\n",
        "  clang_getTypedefDeclUnderlyingType(CXType,Typedef,)\n",
        "  clang_getEnumDeclIntegerType(CXType,Typedef,)\n",
        "  clang_getEnumConstantDeclValue(Typedef,)\n",
        "  clang_getEnumConstantDeclUnsignedValue(Typedef,)\n",
        "  clang_getFieldDeclBitWidth(Typedef,)\n",
        "  clang_Cursor_getNumArguments(Typedef,)\n",
        "  clang_Cursor_getArgument(CXCursor,Typedef,UInt,)\n",
        "  clang_equalTypes(Typedef,Typedef,)\n",
        "  clang_getCanonicalType(CXType,Typedef,)\n",
        "  clang_isConstQualifiedType(Typedef,)\n",
        "  clang_isVolatileQualifiedType(Typedef,)\n",
        "  clang_isRestrictQualifiedType(Typedef,)\n",
        "  clang_getPointeeType(CXType,Typedef,)\n",
        "  clang_getTypeDeclaration(CXCursor,Typedef,)\n",
        "  clang_getDeclObjCTypeEncoding(CXString,Typedef,)\n",
        "  clang_getTypeKindSpelling(CXString,Unexposed,)\n",
        "  clang_getFunctionTypeCallingConv(enum CXCallingConv,Typedef,)\n",
        "  clang_getResultType(CXType,Typedef,)\n",
        "  clang_getNumArgTypes(Typedef,)\n",
        "  clang_getArgType(CXType,Typedef,UInt,)\n",
        "  clang_isFunctionTypeVariadic(Typedef,)\n",
        "  clang_getCursorResultType(CXType,Typedef,)\n",
        "  clang_isPODType(Typedef,)\n",
        "  clang_getElementType(CXType,Typedef,)\n",
        "  clang_getNumElements(Typedef,)\n",
        "  clang_getArrayElementType(CXType,Typedef,)\n",
        "  clang_getArraySize(Typedef,)\n",
        "  clang_Type_getAlignOf(Typedef,)\n",
        "  clang_Type_getSizeOf(Typedef,)\n",
        "  clang_Type_getOffsetOf(Typedef,Ptr{Char_S},)\n",
        "  clang_Cursor_isBitField(Typedef,)\n",
        "  clang_isVirtualBase(Typedef,)\n",
        "  clang_getCXXAccessSpecifier(enum CX_CXXAccessSpecifier,Typedef,)\n",
        "  clang_getNumOverloadedDecls(Typedef,)\n",
        "  clang_getOverloadedDecl(CXCursor,Typedef,UInt,)\n",
        "  clang_getIBOutletCollectionType(CXType,Typedef,)\n",
        "  clang_visitChildren(Typedef,Typedef,Typedef,)\n",
        "  clang_getCursorUSR(CXString,Typedef,)\n",
        "  clang_constructUSR_ObjCClass(CXString,Ptr{Char_S},)\n",
        "  clang_constructUSR_ObjCCategory(CXString,Ptr{Char_S},Ptr{Char_S},)\n",
        "  clang_constructUSR_ObjCProtocol(CXString,Ptr{Char_S},)\n",
        "  clang_constructUSR_ObjCIvar(CXString,Ptr{Char_S},Typedef,)\n",
        "  clang_constructUSR_ObjCMethod(CXString,Ptr{Char_S},UInt,Typedef,)\n",
        "  clang_constructUSR_ObjCProperty(CXString,Ptr{Char_S},Typedef,)\n",
        "  clang_getCursorSpelling(CXString,Typedef,)\n",
        "  clang_Cursor_getSpellingNameRange(CXSourceRange,Typedef,UInt,UInt,)\n",
        "  clang_getCursorDisplayName(CXString,Typedef,)\n",
        "  clang_getCursorReferenced(CXCursor,Typedef,)\n",
        "  clang_getCursorDefinition(CXCursor,Typedef,)\n",
        "  clang_isCursorDefinition(Typedef,)\n",
        "  clang_getCanonicalCursor(CXCursor,Typedef,)\n",
        "  clang_Cursor_getObjCSelectorIndex(Typedef,)\n",
        "  clang_Cursor_isDynamicCall(Typedef,)\n",
        "  clang_Cursor_getReceiverType(CXType,Typedef,)\n",
        "  clang_Cursor_getObjCPropertyAttributes(Typedef,UInt,)\n",
        "  clang_Cursor_getObjCDeclQualifiers(Typedef,)\n",
        "  clang_Cursor_isVariadic(Typedef,)\n",
        "  clang_Cursor_getCommentRange(CXSourceRange,Typedef,)\n",
        "  clang_Cursor_getRawCommentText(CXString,Typedef,)\n",
        "  clang_Cursor_getBriefCommentText(CXString,Typedef,)\n",
        "  clang_Cursor_getParsedComment(CXComment,Typedef,)\n",
        "  clang_Cursor_getModule(CXModule,Typedef,)\n",
        "  clang_Module_getASTFile(CXFile,Typedef,)\n",
        "  clang_Module_getParent(CXModule,Typedef,)\n",
        "  clang_Module_getName(CXString,Typedef,)\n",
        "  clang_Module_getFullName(CXString,Typedef,)\n",
        "  clang_Module_getNumTopLevelHeaders(Typedef,Typedef,)\n",
        "  clang_Module_getTopLevelHeader(CXFile,Typedef,Typedef,UInt,)\n",
        "  clang_Comment_getKind(enum CXCommentKind,Typedef,)\n",
        "  clang_Comment_getNumChildren(Typedef,)\n",
        "  clang_Comment_getChild(CXComment,Typedef,UInt,)\n",
        "  clang_Comment_isWhitespace(Typedef,)\n",
        "  clang_InlineContentComment_hasTrailingNewline(Typedef,)\n",
        "  clang_TextComment_getText(CXString,Typedef,)\n",
        "  clang_InlineCommandComment_getCommandName(CXString,Typedef,)\n",
        "  clang_InlineCommandComment_getRenderKind(enum CXCommentInlineCommandRenderKind,Typedef,)\n",
        "  clang_InlineCommandComment_getNumArgs(Typedef,)\n",
        "  clang_InlineCommandComment_getArgText(CXString,Typedef,UInt,)\n",
        "  clang_HTMLTagComment_getTagName(CXString,Typedef,)\n",
        "  clang_HTMLStartTagComment_isSelfClosing(Typedef,)\n",
        "  clang_HTMLStartTag_getNumAttrs(Typedef,)\n",
        "  clang_HTMLStartTag_getAttrName(CXString,Typedef,UInt,)\n",
        "  clang_HTMLStartTag_getAttrValue(CXString,Typedef,UInt,)\n",
        "  clang_BlockCommandComment_getCommandName(CXString,Typedef,)\n",
        "  clang_BlockCommandComment_getNumArgs(Typedef,)\n",
        "  clang_BlockCommandComment_getArgText(CXString,Typedef,UInt,)\n",
        "  clang_BlockCommandComment_getParagraph(CXComment,Typedef,)\n",
        "  clang_ParamCommandComment_getParamName(CXString,Typedef,)\n",
        "  clang_ParamCommandComment_isParamIndexValid(Typedef,)\n",
        "  clang_ParamCommandComment_getParamIndex(Typedef,)\n",
        "  clang_ParamCommandComment_isDirectionExplicit(Typedef,)\n",
        "  clang_ParamCommandComment_getDirection(enum CXCommentParamPassDirection,Typedef,)\n",
        "  clang_TParamCommandComment_getParamName(CXString,Typedef,)\n",
        "  clang_TParamCommandComment_isParamPositionValid(Typedef,)\n",
        "  clang_TParamCommandComment_getDepth(Typedef,)\n",
        "  clang_TParamCommandComment_getIndex(Typedef,UInt,)\n",
        "  clang_VerbatimBlockLineComment_getText(CXString,Typedef,)\n",
        "  clang_VerbatimLineComment_getText(CXString,Typedef,)\n",
        "  clang_HTMLTagComment_getAsString(CXString,Typedef,)\n",
        "  clang_FullComment_getAsHTML(CXString,Typedef,)\n",
        "  clang_FullComment_getAsXML(CXString,Typedef,)\n",
        "  clang_CXXMethod_isStatic(Typedef,)\n",
        "  clang_CXXMethod_isVirtual(Typedef,)\n",
        "  clang_getTemplateCursorKind(enum CXCursorKind,Typedef,)\n",
        "  clang_getSpecializedCursorTemplate(CXCursor,Typedef,)\n",
        "  clang_getCursorReferenceNameRange(CXSourceRange,Typedef,UInt,UInt,)\n",
        "  clang_getTokenKind(CXTokenKind,Typedef,)\n",
        "  clang_getTokenSpelling(CXString,Typedef,Typedef,)\n",
        "  clang_getTokenLocation(CXSourceLocation,Typedef,Typedef,)\n",
        "  clang_getTokenExtent(CXSourceRange,Typedef,Typedef,)\n",
        "  clang_tokenize(Typedef,Typedef,Ptr{Ptr{Typedef}},Ptr{UInt},)\n",
        "  clang_annotateTokens(Typedef,Ptr{Typedef},UInt,Ptr{Typedef},)\n",
        "  clang_disposeTokens(Typedef,Ptr{Typedef},UInt,)\n",
        "  clang_getCursorKindSpelling(CXString,Unexposed,)\n",
        "  clang_getDefinitionSpellingAndExtent(Typedef,Ptr{Ptr{Char_S}},Ptr{Ptr{Char_S}},Ptr{UInt},Ptr{UInt},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_enableStackTraces()\n",
        "  clang_executeOnThread(Ptr{Unexposed},Ptr{Void},UInt,)\n",
        "  clang_getCompletionChunkKind(enum CXCompletionChunkKind,Typedef,UInt,)\n",
        "  clang_getCompletionChunkText(CXString,Typedef,UInt,)\n",
        "  clang_getCompletionChunkCompletionString(CXCompletionString,Typedef,UInt,)\n",
        "  clang_getNumCompletionChunks(Typedef,)\n",
        "  clang_getCompletionPriority(Typedef,)\n",
        "  clang_getCompletionAvailability(enum CXAvailabilityKind,Typedef,)\n",
        "  clang_getCompletionNumAnnotations(Typedef,)\n",
        "  clang_getCompletionAnnotation(CXString,Typedef,UInt,)\n",
        "  clang_getCompletionParent(CXString,Typedef,Ptr{Unexposed},)\n",
        "  clang_getCompletionBriefComment(CXString,Typedef,)\n",
        "  clang_getCursorCompletionString(CXCompletionString,Typedef,)\n",
        "  clang_defaultCodeCompleteOptions()\n",
        "  clang_codeCompleteAt(CXCodeCompleteResults,Typedef,Ptr{Char_S},UInt,UInt,Ptr{Unexposed},UInt,UInt,)\n",
        "  clang_sortCodeCompletionResults(Ptr{Typedef},UInt,)\n",
        "  clang_disposeCodeCompleteResults(Ptr{Typedef},)\n",
        "  clang_codeCompleteGetNumDiagnostics(Ptr{Typedef},)\n",
        "  clang_codeCompleteGetDiagnostic(CXDiagnostic,Ptr{Typedef},UInt,)\n",
        "  clang_codeCompleteGetContexts(Ptr{Typedef},)\n",
        "  clang_codeCompleteGetContainerKind(enum CXCursorKind,Ptr{Typedef},Ptr{UInt},)\n",
        "  clang_codeCompleteGetContainerUSR(CXString,Ptr{Typedef},)\n",
        "  clang_codeCompleteGetObjCSelector(CXString,Ptr{Typedef},)\n",
        "  clang_getClangVersion(CXString,)\n",
        "  clang_toggleCrashRecovery(UInt,)\n",
        "  clang_getInclusions(Typedef,Typedef,Typedef,)\n",
        "  clang_getRemappings(CXRemapping,Ptr{Char_S},)\n",
        "  clang_getRemappingsFromFileList(CXRemapping,Ptr{Ptr{Char_S}},UInt,)\n",
        "  clang_remap_getNumFiles(Typedef,)\n",
        "  clang_remap_getFilenames(Typedef,UInt,Ptr{Typedef},Ptr{Typedef},)\n",
        "  clang_remap_dispose(Typedef,)\n",
        "  clang_findReferencesInFile(CXResult,Typedef,Typedef,Typedef,)\n",
        "  clang_findIncludesInFile(CXResult,Typedef,Typedef,Typedef,)\n",
        "  clang_index_isEntityObjCContainerKind(Typedef,)\n",
        "  clang_index_getObjCContainerDeclInfo(CXIdxObjCContainerDeclInfo,Ptr{Typedef},)\n",
        "  clang_index_getObjCInterfaceDeclInfo(CXIdxObjCInterfaceDeclInfo,Ptr{Typedef},)\n",
        "  clang_index_getObjCCategoryDeclInfo(CXIdxObjCCategoryDeclInfo,Ptr{Typedef},)\n",
        "  clang_index_getObjCProtocolRefListInfo(CXIdxObjCProtocolRefListInfo,Ptr{Typedef},)\n",
        "  clang_index_getObjCPropertyDeclInfo(CXIdxObjCPropertyDeclInfo,Ptr{Typedef},)\n",
        "  clang_index_getIBOutletCollectionAttrInfo(CXIdxIBOutletCollectionAttrInfo,Ptr{Typedef},)\n",
        "  clang_index_getCXXClassDeclInfo(CXIdxCXXClassDeclInfo,Ptr{Typedef},)\n",
        "  clang_index_getClientContainer(CXIdxClientContainer,Ptr{Typedef},)\n",
        "  clang_index_setClientContainer(Ptr{Typedef},Typedef,)\n",
        "  clang_index_getClientEntity(CXIdxClientEntity,Ptr{Typedef},)\n",
        "  clang_index_setClientEntity(Ptr{Typedef},Typedef,)\n",
        "  clang_IndexAction_create(CXIndexAction,Typedef,)\n",
        "  clang_IndexAction_dispose(Typedef,)\n",
        "  clang_indexSourceFile(Typedef,Typedef,Ptr{Typedef},UInt,UInt,Ptr{Char_S},Ptr{Ptr{Char_S}},Int,Ptr{Unexposed},UInt,Ptr{Typedef},UInt,)\n",
        "  clang_indexTranslationUnit(Typedef,Typedef,Ptr{Typedef},UInt,UInt,Typedef,)\n",
        "  clang_indexLoc_getFileLocation(Typedef,Ptr{Typedef},Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)\n",
        "  clang_indexLoc_getCXSourceLocation(CXSourceLocation,Typedef,)\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Printing Structs\n",
      "================\n",
      "\n",
      "Expected output:\n",
      "```\n",
      "Struct: CXTranslationUnitImpl\n",
      "Struct: CXUnsavedFile\n",
      "Struct: CXVersion\n",
      "Struct: CXVersion\n",
      "Struct: \n",
      "Struct: \n",
      "```\n",
      "Note: it takes a little bit more work to get the name of typedef'd structs. See Clang.jl/src/wrap_c.jl for a full implementation."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "using Clang.cindex\n",
      "\n",
      "get_struct(t::TypedefDecl) = get_struct(cindex.getTypeDeclaration(cindex.getTypedefDeclUnderlyingType(t)))\n",
      "get_struct(d::StructDecl)  = d\n",
      "get_struct(d::CLCursor)    = Union{}\n",
      "\n",
      "function dump_structs(hdr::String)\n",
      "    topcu = parse_header(hdr; includes = clang_includes)\n",
      "    for cu in children(topcu)\n",
      "        # Skip includes\n",
      "        if (basename(cu_file(cu)) != basename(hdr)) continue end\n",
      "        cur = get_struct(cu)\n",
      "        if (cur != Union{})\n",
      "            println(\"Struct: \", name(cur))\n",
      "        end\n",
      "    end\n",
      "end\n",
      "\n",
      "dump_structs(indexh)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Struct: CXTranslationUnitImpl"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Struct: CXUnsavedFile\n",
        "Struct: CXVersion\n",
        "Struct: CXVersion\n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: CXTUResourceUsageEntry\n",
        "Struct: CXTUResourceUsageEntry\n",
        "Struct: CXTUResourceUsage\n",
        "Struct: CXTUResourceUsage\n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: CXPlatformAvailability\n",
        "Struct: CXPlatformAvailability\n",
        "Struct: CXCursorSetImpl\n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n",
        "Struct: \n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}